#

| Chapter 24 Other Ways to Get Disk Space |

## 24.5 Limiting File Sizes

Here is a technique to keep you from creating large files (which can happen by accident, such as runaway programs). To set a maximum file size, use the C shell command (usually in your .cshrc file) `limit filesize` `max-size`. In the Korn shell and bash, use `ulimit -f` `max-size`. You can change the limit from the command line, too. For example, the csh and ksh commands below keep you from creating any files larger than 2 megabytes:

>     % limit filesize 2m
>     $ ulimit -f 2000

With this command, UNIX will refuse to allocate more disk space to any file that grows larger than 2 MB.

Similarly, on Berkeley systems, you can use limit and ulimit to restrict the size of core dump files (52.9). Core dumps are generally large files and are often generated for innocuous reasons, such as invoking commands incorrectly. To set a maximum size for core dumps, execute one of these commands:

>     % limit coredumpsize max-size
>     $ ulimit -c max-size

To eliminate core dumps entirely, use `0` (zero) for `max-size`. Because core dumps are essential for effective debugging, any users who are actively debugging programs should know the commands `unlimit coredumpsize`, which removes this restriction in csh-and `ulimit -c unlimited` for bash and ksh.

- ML from O'Reilly & Associates' System Performance Tuning, Chapter 5

24.4 Save Space with a Link |  | 24.6 Save Space with Tab Characters